﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using UpdaterForm;

namespace TestProject
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestSerialize()
        {
            var conf = new Configuration
            {
                Data = new Data
                {
                    AppData = new List<AppData>
                    {
                        new AppData { AppName = "Watchdog", CurrentVersion = "20140719", InstallationPath = @"C:\Thesis\Watchdog" },
                        new AppData { AppName = "Wire", CurrentVersion = "20140719", InstallationPath = @"C:\Thesis\Wire"}
                    }
                },
              
                DateFormat = "yyyyMMdd",
                MessageFileName = "readme.txt",
                RepositoryPath = @"W:\Study\Updater\Repo"
                
            };
            var writer = new XmlSerializer(typeof(Configuration));
            var file = new StreamWriter(@"C:\Thesis\Conf.xml");
            writer.Serialize(file, conf);
            file.Close();
        }

        [TestMethod]
        public void TestDeserialize(){
            var serializer = new XmlSerializer(typeof(Configuration));
            Configuration conf;
            using (StreamReader reader = new StreamReader(@"C:\Thesis\Conf.xml")){
                conf = (Configuration)serializer.Deserialize(reader);
            }

            var c = conf;
           
        }
    }
}
